cmake_minimum_required(VERSION 3.16)
project(joint_state_broadcaster LANGUAGES CXX)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
  add_compile_options(-Wall -Wextra -Wconversion)
endif()

set(THIS_PACKAGE_INCLUDE_DEPENDS
  builtin_interfaces
  control_msgs
  controller_interface
  generate_parameter_library
  pluginlib
  rclcpp_lifecycle
  rcutils
  realtime_tools
  sensor_msgs
)

find_package(ament_cmake REQUIRED)
find_package(backward_ros REQUIRED)
find_package(Boost REQUIRED COMPONENTS system)

foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
  find_package(${Dependency} REQUIRED)
endforeach()

generate_parameter_library(joint_state_broadcaster_parameters
  src/joint_state_broadcaster_parameters.yaml
)

add_library(joint_state_broadcaster SHARED
  src/joint_state_broadcaster.cpp
)
target_compile_features(joint_state_broadcaster PUBLIC cxx_std_17)
target_include_directories(joint_state_broadcaster PUBLIC
  $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include/joint_state_broadcaster>
)
target_link_libraries(joint_state_broadcaster PUBLIC
  joint_state_broadcaster_parameters
)
ament_target_dependencies(joint_state_broadcaster PUBLIC ${THIS_PACKAGE_INCLUDE_DEPENDS})
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(joint_state_broadcaster PRIVATE "JOINT_STATE_BROADCASTER_BUILDING_DLL")
pluginlib_export_plugin_description_file(controller_interface joint_state_plugin.xml)

install(
  DIRECTORY include/
  DESTINATION include/joint_state_broadcaster
)
install(
  TARGETS
    joint_state_broadcaster
    joint_state_broadcaster_parameters
  EXPORT export_joint_state_broadcaster
  RUNTIME DESTINATION bin
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
)

ament_export_targets(export_joint_state_broadcaster HAS_LIBRARY_TARGET)
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})
ament_package()
